var fullscreen = {
  full: function() {
    $("aside").css("overflow", "hidden").animate({ "width": "0" }, 200);
    $("header").css("overflow", "hidden").animate({ "height": "0" }, 200);
    $(".right_con").animate({ "padding-bottom": "15px" }, 200);
    if ($(".left_menu").is(":visible")) {
      $(".right_con .btnBox").animate({ "left": "148px" }, 200);
    } else {
      $(".right_con .btnBox").animate({ "left": "13px" }, 200);
    }
  },
  restore: function() {
    if ($("aside").hasClass("open")) {
      $("aside").css("overflow", "visible").animate({ "width": "50px" }, 200);
      $("header").css("overflow", "visible").animate({ "height": "55px" }, 200);
      $(".right_con").animate({ "padding-bottom": "70px" }, 200);
      if ($(".left_menu").is(":visible")) {
        $(".right_con .btnBox").animate({ "left": "198px" }, 200);
      } else {
        $(".right_con .btnBox").animate({ "left": "63px" }, 200);
      }
    } else {
      $("aside").css("overflow", "visible").animate({ "width": "185px" }, 200);
      $("header").css("overflow", "visible").animate({ "height": "55px" }, 200);
      $(".right_con").animate({ "padding-bottom": "70px" }, 200);
      if ($(".left_menu").is(":visible")) {
        $(".right_con .btnBox").animate({ "left": "333px" }, 200);
      } else {
        $(".right_con .btnBox").animate({ "left": "198px" }, 200);
      }
    }
  }
};

$(function() {
  var modifypwdUrl = '' //site.interUrl+"/content_page/personalcenter/modifypwd.html?groupid=6c68aa01ba4e4fe193fadbe22ef0610e&iconid=6ecda0648be341fcb333e124b192577e&subid=6f7ca07feb1640c78ae7a4243a2947ad&menuid=703e38316e1149eb802c2cf95e88bae4";
  var userLoginName = window.localStorage.getItem("backstage-access-name") || '管理员';
  var side = '<aside>';
  side += '<div class="left_top">';
  side += '</div>';
  side += '<div class="left_header">';
  // side += '<div class="head_wrap">';
  // side += '<div class="head"><img src="' + site.interUrl + '/img/default_head.jpg" alt="" /></div>';
  // side += '<div class="name">' + userLoginName + '</div>';
  // side += '</div>';
  side += '<div class="menu_groups">';
  side += '<a href="JavaScript:;"><i class="iconfont icon-tuichu"></i><span>退出</span></a>';
  side += '</div>';
  side += '</aside>';
  var header = '<header>';
  header += '<div class="fl">';
  header += '<div class="shrink"> <i class="iconfont icon-daohang1"></i> </div>';
  header += '<div class="tmenu quick"></div>';
  header += '</div>';
  header += '<div class="fr">';
  // header += '<a class="ticon msg" title="消息"> <em id="unreadnum" class="hide"></em> <i class="iconfont icon-xiaoxi1"></i> </a>';
  header += '<div class="top-header-login-name">' + userLoginName + '</div>';
  header += '<div class="ticon help quit"> <i class="iconfont icon-tuichu"></i> </div>';
  header += '</div>';
  header += '</header>';
  $("body").prepend(side);
  $("aside").after(header);
  $(".btnBox").parents('.infoBox').css("margin-bottom", "56px");
  $(".shrink").click(function() {
    if ($(this).hasClass("open")) {
      if ($(".btnBox").length) {
        $(".btnBox").animate({ "left": $(".btnBox").offset().left + 135 }, 400);
      }
      $(window).resize();
      $("aside").animate({ "width": 185 }, 400, function() {
        $("aside").removeClass("open");
        $(window).resize();
      });
      $(this).removeClass("open");
      $("aside").find(".head").animate({ "width": 70, "height": 70 }, 400);
      $("aside").find(".menu_groups a").animate({ "padding-left": 50 }, 400);
    } else {
      if ($(".btnBox").length) {
        $(".btnBox").animate({ "left": $(".btnBox").offset().left - 135 }, 400);
      }
      $("aside").animate({ "width": 50 }, 400, function() {
        $(window).resize();
      });
      $(this).addClass("open");
      $("aside").addClass("open");
      $("aside").find(".head").animate({ "width": 43, "height": 43 });
      $("aside").find(".menu_groups a").animate({ "padding-left": 14 }, 400);
    }
  });
  $(".tico.full").click(function() {
    if ($(this).hasClass("open")) {
      fullscreen.restore();
      $(this).removeClass("open");
    } else {
      fullscreen.full();
      $(this).addClass("open");
    }
  });

  // $(".quick").syMenu({
  //   menuName: "快速导航",
  //   target: "",
  //   list: [
  //     { text: "百度", href: "http://www.baidu.com" },
  //     { text: "菜单项", href: "http://www.86y.org" },
  //     { text: "菜单项", href: "http://www.google.com" }
  //   ]
  // });
  ly.getMenuData();

  //退出
  $(".quit").on("click", function() {
    ly.confirm("您确定退出吗？", function(r) {
      removeStorage();
      delCookie("userName", '');
      delCookie("userPass", '');
      // ly.toast("退出成功", site.interUrl + "login.html");
      ly.goto(site.interUrl + "login.html");
      // var url = site.interUrl + '/sUsers/logout';
      // request({
      //   url: url,
      //   data: {},
      //   type: "post",
      //   callback: function(f) {
      //     console.log(f);
      //     if (f.code == "rest.success") {
      //       removeStorage();
      //       delCookie("userName", '');
      //       delCookie("userPass", '');
      //       var thisPage = window.location.href;
      //       ly.toast("退出成功", site.interUrl + "login.html");
      //     }
      //   }
      // });
    });
  });

});
//清除localStorage
function removeStorage() {
  window.localStorage.removeItem("backstage-access-token");
  window.localStorage.removeItem("backstage-access-id");
  window.localStorage.removeItem("backstage-access-account");
  window.localStorage.removeItem("backstage-access-headPicUrl");
  window.localStorage.removeItem("backstage-access-nickName");
  window.localStorage.removeItem("backstage-access-name");
  window.localStorage.removeItem("backstage-access-businessId");
  window.localStorage.removeItem("backstage-access-roleName");
  window.localStorage.removeItem("backstage-access-roleId");
  window.localStorage.removeItem("backstage-access-personnelType");
  window.localStorage.removeItem("backstage-access-personnelstyle");
  window.localStorage.removeItem("backstage-access-permissionList");
}
//清除cookie
function delCookie(cname, cvalue) {
  var expires = "expires=-1";
  document.cookie = cname + "=''; " + expires + ";path=/";
}

// 查询所有菜单 /menu/menuList


